import Vue from 'vue';
import hCore, { store } from '@hsui/core';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './reset.css';
import * as echarts from 'echarts';
import h_ui from 'h_ui';
import 'h_ui/dist/h_ui.min.css';
import 'animate.css';
import '@/js/jquery-1.11.0.min'
import '@/js/polygonizr.min'
import Chat from 'vue-beautiful-chat'
import Vue2OrgTree from 'vue2-org-tree'

Vue.use(Vue2OrgTree)
Vue.use(Chat)
Vue.use(h_ui);
Vue.use(ElementUI);
Vue.prototype.$echarts = echarts;

const app = hCore({
  extraModelOptions: {
    store,
  },
});

app.middleware('before-route-change', (to, from, next) => {
  const token = store.getters['operator/token'];
  if(token === '' && to.path !== '/') {
    next('/');
  } else {
    next();
  }
});

app.start();
